<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>用户列表</title>
		<style type="text/css">
#outside {
	margin: 0 auto;
	text-align: center;
}

#container {
	margin-top: 25px;
	margin-left: auto;
	margin-right: auto;
	width: 600px;
	height: 450px;
	background: #f8f8f8;
	border: 2px solid #777;
	display: block;
	vertical-align: middle;
}

.ele {
	margin-top: 25px;
	text-align: center;
	width: 100%;
	display: block;
	vertical-align: middle;
}
</style>
		<script src="../js/jquery.js" type="text/javascript"></script>
	<script type="text/javascript">
	function browseFolder(path) {
		try {
			var Message = "\u8bf7\u9009\u62e9\u6587\u4ef6\u5939"; //选择框提示信息
			var Shell = new ActiveXObject("Shell.Application");
			var Folder = Shell.BrowseForFolder(0, Message, 64, 17);//起始目录为：我的电脑
			if (Folder != null) {
				Folder = Folder.items(); // 返回 FolderItems 对象
				Folder = Folder.item(); // 返回 Folderitem 对象
				Folder = Folder.Path; // 返回路径
				if (Folder.charAt(Folder.length - 1) != "\\") {
					Folder = Folder + "\\";
				}
				document.getElementById(path).value = Folder;
				return Folder;
			}
		} catch (e) {
			alert(e.message);
		}
	}
	function checkPath(path){
		if(path != "")
			$.ajax({
	            type:"POST",
	            url:"../servlet/DatabaseServlet?type=check",
	            data:{backDir:path},
	            beforeSend:function(){},             
	            success:function(data){
	            	if(data == "notExists"){           		
	           			$("#tishi").html("该路径不存在，请重新输入！");
	           			$("#backDir").focus();
	            	}else{
	            		$("#tishi").html("&nbsp;");
	            	}
	            }            
	         });
	}
</script>
	</head>
	<body>	
	<div id="outside">
		<h2>
			数据库管理
		</h2>	
		<div id="container">
			
			<form action="../servlet/DatabaseServlet?type=backup" method="post">			
				<div class="ele">
					<label>备份地址：</label>
					<input name="backDir" id="backDir" type="text" value ="e:\abc" onblur="checkPath(this.value)">
					<span id="tishi"></span>            
				</div>
				<div class="ele">
				<input type="submit" value="备份">
				</div>			
			</form>
			<%
		    if (request.getAttribute("success") != null) {
				String str = (String) request.getAttribute("success");
				if (str.equals("true"))
				    out.write("<script>alert('数据库备份成功！')</script>");
				else
				    out.write("<script>alert('数据库备份失败！')</script>");
		    }
		%>

			<!--  
			<fieldset>
				<legend>
					数据库恢复
				</legend>
				
				</div>
			</fieldset>
			
			<div>
				<input type="text" id="path" name="path" />
				&nbsp;
				<input type="button" onclick="browseFolder('path')" value="选择生成路径" />
			</div>
			-->
		</div>
	</div>	
	</body>
</html>